<?xml version='1.0' encoding='UTF-8' ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
      xmlns:ui="http://java.sun.com/jsf/facelets"
      xmlns:h="http://java.sun.com/jsf/html"
      xmlns:f="http://java.sun.com/jsf/core"
      xmlns:p="http://primefaces.prime.com.tr/ui">

    <body>


        <ui:composition template="./../../Template/generalTemplate.xhtml">
            <ui:define name="content">
                <h:form id="form" prependId="false">
                    <f:view beforePhase="#{viewProductBatchRecordsManagedBean.initView}">
                        <p:panel header="View Product Batch Records" style="height:495px;">
                            <div style="margin-top:20px;margin-left:100px;margin-right:100px;">
                                <p:dataTable scrollable="true" height="280" id="table" var="records" widgetVar="carsTable" value="#{viewProductBatchRecordsManagedBean.getProductRecords()}" emptyMessage="No records found with given criteria" selection="#{viewProductBatchRecordsManagedBean.selectedBatch}" selectionMode="single">  

                                    <f:facet name="header">  
                                        <p:outputPanel>  
                                            <h:outputText value="Search all fields:" />  
                                            <p:inputText id="globalFilter" onkeyup="carsTable.filter()" style="width:150px" />  
                                        </p:outputPanel>  
                                    </f:facet>  

                                    <p:column filterBy="#{records.id}"   
                                              headerText="Batch id" footerText="contains"  
                                              filterMatchMode="contains" style="width:100px">  
                                        <h:outputText value="#{records.id}" />  
                                    </p:column>  

                                    <p:column  style="width:110px" filterBy="#{records.productInventoryLevel.product.productName}"  
                                               headerText="Product Name" footerText="endsWith"  filterMatchMode="endsWith">  
                                        <h:outputText value="#{records.productInventoryLevel.product.productName}" />  
                                    </p:column>  

                                    <p:column  style="width:115px" filterBy="#{records.manufactureDate}"   
                                               headerText="Manufacturer Date" footerText="contains"  

                                               filterMatchMode="contains">  

                                        <h:outputText value="#{records.manufactureDate}" >
                                            <f:convertDateTime pattern="dd/MM/yyyy"/>
                                        </h:outputText>
                                    </p:column>  

                                    <p:column  style="width:105px" filterBy="#{records.quantity}"  
                                               headerText="Quantity" footerText="startsWith" filterMatchMode="startsWith">  
                                        <h:outputText value="#{records.quantity}" />  
                                    </p:column>  

                                    <p:column style="width:130px" filterBy="#{records.productInventoryLevel.product.warehouseLocation}"  
                                              headerText="Warehouse Location" footerText="endsWith" filterMatchMode="endsWith">  
                                        <h:outputText value="#{records.productInventoryLevel.product.warehouseLocation}" />  
                                    </p:column>  

                                    <p:column style="width:110px;text-align:center;" filterBy="#{records.reserved}"  
                                              headerText="Reserve Status" footerText="exact" filterMatchMode="exact">  
                                        <h:outputText style="color:red;" value="Reserved" rendered="#{records.reserved}" />  
                                        <h:outputText style="color:blue;" value="Not Reserved" rendered="#{!records.reserved}" />  

                                    </p:column>  

                                    <f:facet name="footer">  
                                        <p:commandButton value="Delete" update="form:table" oncomplete="confirmation.show()"  image="ui-icon ui-icon-close" rendered="#{viewProductBatchRecordsManagedBean.canDelete}"/>
                                    </f:facet>  
                                </p:dataTable>  
                                <p:confirmDialog message="Are you sure to delete?" 
                                                 showEffect="explode"
                                                 header="Confirm" severity="alert" widgetVar="confirmation">  

                                    <p:commandButton value="Confirm" update="form" actionListener="#{viewProductBatchRecordsManagedBean.deleteRecord}" oncomplete="confirmation.hide()">  


                                    </p:commandButton>
                                    <p:commandButton value="Cancel" onclick="confirmation.hide()" type="button" />  

                                </p:confirmDialog>

                            </div>
                        </p:panel>
                    </f:view>
                </h:form>
            </ui:define>
        </ui:composition>



    </body>
</html>
